package com.androidian.tippit.fragments;

import com.androidian.tippit.ActivityHome;
import com.androidian.tippit.R;
import com.androidian.tippit.utilities.Fonts;
import com.androidian.tippit.utilities.Callbacks.StandardVariables;
import com.androidian.tippit.utilities.Callbacks.WizardLocker;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.NumberPicker;
import android.widget.NumberPicker.OnValueChangeListener;

public class FragmentPeopleNumber extends Fragment
{
	
	
	private StandardVariables mStandardVariables;
	
	private WizardLocker mWizardLocker;

	private ActivityHome mActivity;

	
	
	@Override
	public void onAttach(Activity activity) 
	{
		super.onAttach(activity);
		
		mStandardVariables = (StandardVariables) activity;
		
		mWizardLocker = (WizardLocker) activity;
		
		mActivity = (ActivityHome) activity;

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
	{
		
		final View view = inflater.inflate(R.layout.fragment_peoplenumber,
				container, false);		
		
		Fonts.setRobotoThinFont(getActivity(), view);
		
		final NumberPicker mNumberPicker = (NumberPicker) 
				view.findViewById(R.id.peopleNumberPicker);

		mNumberPicker.setMinValue(1);
		mNumberPicker.setMaxValue(50);
		mNumberPicker.setWrapSelectorWheel(true);
		mNumberPicker.setValue(mActivity.peopleNumber);
		
		
		
		mNumberPicker.setOnValueChangedListener(new OnValueChangeListener()
		{

			@Override
			public void onValueChange(NumberPicker picker, int oldVal, int newVal) 
			{
				
				mStandardVariables.peopleNumberSet(newVal);
				
				mStandardVariables.calculateTotals();
				
			}

		});
		
		return view;
		
	}
	
	
	@Override
	public void setUserVisibleHint(boolean isVisibleToUser) 
	{
		super.setUserVisibleHint(isVisibleToUser);

		if (isVisibleToUser) 
		{
			
			mWizardLocker.unlockNavigation(true, true, true);
							
		}

	}

}
